package com.vzaar;

/**
 * Response from signature request that contains the GUID and an AWS S3  
 * signature. With these credentials the user will then be able upload a 
 * file into <a href="http://vzaar.com">vzaar</a> video storage area.
 * 
 * @author Marc G. Smith
 */
class UploadSignature 
{
	///////////////////////////////////////////////////////////////////////////
	// Private Members ////////////////////////////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	
	private String guid;
	private String key;
	private boolean https;
	private String acl;
	private String bucket;
	private String policy;
	private String expirationDate;
	private String accessKeyId;
	private String signature;
	
	///////////////////////////////////////////////////////////////////////////
	// Public and Package Protected Methods ///////////////////////////////////
	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * Package protected constructor.
	 * 
	 * @param guid the vzaar global unique identifier
	 * @param key a name for the S3 object that will store the uploaded 
	 * 		file's data
	 * @param https 
	 * @param acl the access control policy to apply to the uploaded file
	 * @param bucket the vzaar bucket that has been allocated for this file
	 * @param policy a Base64-encoded policy document that applies rules to 
	 * 	file uploads sent by the S3 POST form. This document is used to authorise 
	 * 	the form, and to impose conditions on the files that can be uploaded.
	 * @param expirationDate s Greenwich Mean Time (GMT) timestamp that 
	 * 	specifies when the policy document will expire. Once a policy document 
	 * 	has expired, the upload will fail
	 * @param accessKey the vzaar AWS Access Key Identifier credential
	 * @param signature a signature value that authorises the form and proves 
	 * 	that only vzaar could have created it. This value is calculated by signing 
	 * 	the policy document
	 */
	UploadSignature(String guid, String key, boolean https, String acl,
			String bucket, String policy, String expirationDate,
			String accessKeyId, String signature) 
	{
		this.guid = guid;
		this.key = key;
		this.https = https;
		this.acl = acl;
		this.bucket = bucket;
		this.policy = policy;
		this.expirationDate = expirationDate;
		this.accessKeyId = accessKeyId;
		this.signature = signature;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * The vzaar global unique identifier.
	 * 
	 * @return the vzaar global unique identifier
	 */
	public String getGuid() {
		return guid;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * A name for the S3 object that will store the uploaded file's data
	 *  
	 * @return a name for the S3 object that will store the uploaded 
	 * 		file's data
	 */
	public String getKey() {
		return key;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * @return the https
	 */
	public boolean isHttps() {
		return https;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * The access control policy to apply to the uploaded file.
	 * 
	 * @return the access control policy to apply to the uploaded file
	 */
	public String getAcl() {
		return acl;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * The vzaar bucket that has been allocated for this file
	 * @return the vzaar bucket that has been allocated for this file
	 */
	public String getBucket() {
		return bucket;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * A Base64-encoded policy document that applies rules to file uploads 
	 * sent by the S3 POST form. This document is used to authorise the form, 
	 * and to impose conditions on the files that can be uploaded.
	 * 
	 * @return a Base64-encoded policy document that applies rules to file 
	 * 		uploads sent by the S3 POST form.
	 */
	public String getPolicy() {
		return policy;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * A Greenwich Mean Time (GMT) timestamp that specifies when the policy 
	 * document will expire. Once a policy document has expired, the upload 
	 * will fail.
	 * 
	 * @return a Greenwich Mean Time (GMT) timestamp that specifies when the 
	 * policy document will expire. 
	 */
	public String getExpirationDate() {
		return expirationDate;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * The vzaar AWS Access Key Identifier credential.
	 * 
	 * @return the vzaar AWS Access Key Identifier credential
	 */
	public String getAccessKeyId() {
		return accessKeyId;
	}

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * A signature value that authorises the form and proves that only vzaar 
	 * could have created it. This value is calculated by signing the policy 
	 * document.
	 * 
	 * @return a signature value that authorizes the form and proves that 
	 * 	only vzaar could have created it
	 */
	public String getSignature() {
		return signature;
	}
	

	///////////////////////////////////////////////////////////////////////////
	
	/**
	 * String representation of the upload document.
	 */
	public String toString() {
		return
			"guid=" + guid +
			", key=" + key +
			", http=" + https +
			", acl=" + acl +
			", bucket=" + bucket +
			", policy=" + policy +
			", expirationdate=" + expirationDate +
			", accesskeyid=" + accessKeyId +
			", signature=" + signature;
	}

	///////////////////////////////////////////////////////////////////////////
}
